#!/bin/bash

set -e
set -o pipefail

CONFIGURE_DIR=$(dirname "$0")
cd "${CONFIGURE_DIR}"

if [ ! -f "/home/jenkins/tensorflow26/.env/bin/activate" ];then
  echo "No venv for tensorflow2.x installed, skip CI build"
  exit 0
fi

source /home/jenkins/tensorflow26/.env/bin/activate

if [ "${OS_TYPE}" = "centos_aarch64" ]; then
    PYTHON_BIN_PATH=$(which python3.7)
else
    PYTHON_BIN_PATH=$(which python3.9)
fi

export ADAPTER_TARGET_PYTHON_PATH="$PYTHON_BIN_PATH"
export ASCEND_INSTALLED_PATH="$ASCEND_HOME_PATH"

"$PYTHON_BIN_PATH" "configure.py" "$@"

echo "Configuration finished"

rm -rf build
mkdir build
cd build
cmake ..
make -j8

deactivate
